home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / parname.cq / parname.c
Text File  |  1986-02-02  |  2KB  |  46 lines

  1. /*
  2.     NAME
  3.         parnam
  4.     SYNOPSIS
  5.         parnam(name,path,fname);
  6.         char *name;     filespec to parse
  7.         char path[FMSIZE]; path (including drive)
  8.         char fname[FNSIZE] filename with possible extension
  9.  
  10.     DESCRIPTION
  11.         This routine parses a string (name) into a path and filename.
  12.  
  13.     RETURNS
  14.         path is filled with any path specification (including drive)
  15.         fname is filled with the filename and possible extension
  16. */
  17.  
  18. /*
  19.                                History:
  20. Version    Date    Author                 Reason
  21. -------  --------  ------  ---------------------------------------------
  22.  1.0     01/15/85   CCW    Original
  23. */
  24. #include <dos.h>
  25. parnam(name,path,fname)
  26. char *name;
  27. char *path;
  28. char *fname;
  29. {
  30.     int i,j;
  31.  
  32.     /* Parse out the path portion of the filename */
  33.     for(i=strlen(name);
  34.         i >= 0 && name[i]!='/' &&  name[i]!=':' && name[i]!='\\';
  35.         i--);
  36.     /* i now should contain the length of the path */
  37.     if(i>0)     stccpy(path,name,i+2);
  38.     else path[0]='\0';
  39.     i++;
  40.     for(j=0;j<FNSIZE && name[i] != '\0';j++) fname[j] = name[i++];
  41.     fname[j] = '\0';
  42. }
  43. 
  44.     fname[j] = '\0';
  45. }
  46.